<style>
    .layui-form .layui-form-item .layui-inline .layui-form-label {
        width: 200px;
        font-size: 18px;
        font-weight: bold;
    }
    .layui-form .layui-form-item .layui-inline .layui-input-inline input{
        width: 250px;
        font-size: 16px;
    }
</style>
<form class="layui-form  seller-alone-form" id="userAdd" style="padding:20px;height: 600px;">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>
            <a href="{:url('source')}" style="color: #428bca;font-weight:bold;" >Cards Fund Source</a> / Add
        </legend>
    </fieldset>
    <br/>
    <br/>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">basic auth username：</label>
            <div class="layui-input-inline">
                <input type="text" name="basic_auth_username"
                       lay-verify="required_en" maxlength="30"
                       lay-verType="tips"  class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">url：</label>
            <div class="layui-input-inline">
                <input type="text" name="url"
                       lay-verify="required_en"  placeholder="demo: https://www.baidu.com"
                       lay-verType="tips"  class="layui-input">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">basic auth password：</label>
            <div class="layui-input-inline">
                <input type="text" name="basic_auth_password"
                       lay-verify="required_en" maxlength="30" placeholder="must be between 20 and 100"
                       lay-verType="tips"  class="layui-input">
            </div>
        </div>

        <div class="layui-inline">
            <label class="layui-form-label">name：</label>
            <div class="layui-input-inline">
                <input type="text" name="name"
                       lay-verify="required_en" maxlength="20"
                       lay-verType="tips"  class="layui-input">
            </div>
        </div>
    </div>
    <br/>
    <span style="padding-left: 200px;font-size: 20px;">basic_auth_password Demo : My_20-character-min_password</span>
    <br/>
    <br/>
    <span style="padding-left: 200px;font-size: 20px;">URL Demo : https://sandboxendpoint.betterepay.com/api/accept</span>
    <div class="layui-form-item" style="padding-top: 100px;">
        <div class="layui-input-block">
            <button type="button" class="layui-btn" lay-submit lay-filter="save">confirm</button>
            <a href="{:url('source')}" class="layui-btn layui-btn-primary">{:lang('back')}</a>
        </div>
    </div>
</form>

<script>
    layui.use(['form'], function () {
        var form = layui.form;

        form.on('submit(save)', function(data){
            JsPost("{:url('cards/sourceAdd')}", data.field, function(res){
                if (res.code > 0) {
                    layer.msg(res.msg, {time: 1500, icon: 1}, function () {
                        window.location.href = "{:url('source')}";
                    });
                } else {
                    layer.msg(res.msg, {time: 1500, icon: 2});
                }
            });
        });
    });
</script>
